package com.example.demo.tools;

import com.example.demo.model.Notice;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WJ
 * Date: 2023-02-13
 * Time: 18:29
 */

// 存放一些使用的常量
public class Constant {

//  session 中的 key 值
    public static final String USER_INFO_SESSION_KEY = "USER_INFO_SESSION_KEY";

//    管理员的菜单
    public static List<HashMap<String,Object>> getAdminMenuList(){
//      总的数组
        List<HashMap<String,Object>> list = new ArrayList<>();

//      人员管理
        HashMap<String,Object> map1 = new HashMap<>();
        map1.put("label","人员管理");
        map1.put("name","persion");
        map1.put("icon","el-icon-s-platform");

        ArrayList<HashMap<String,String>> arrayList1 = new ArrayList<>();
        HashMap<String,String> map1_1 = new HashMap<>();
        map1_1.put("label","管理模块");
        map1_1.put("path","adminManage");
        map1_1.put("name","adminManage");
        arrayList1.add(map1_1);

        HashMap<String,String> map1_2 = new HashMap<>();
        map1_2.put("label","员工模块");
        map1_2.put("path","employeeManage");
        map1_2.put("name","employeeManage");
        arrayList1.add(map1_2);

        HashMap<String,String> map1_4 = new HashMap<>();
        map1_4.put("label","员工评价");
        map1_4.put("path","commentUser");
        map1_4.put("name","commentUser");
        arrayList1.add(map1_4);

        HashMap<String,String> map1_3 = new HashMap<>();
        map1_3.put("label","老人模块");
        map1_3.put("path","olderManage");
        map1_3.put("name","olderManage");
        arrayList1.add(map1_3);

        map1.put("children",arrayList1);

// 健康管理
        HashMap<String,Object> map2 = new HashMap<>();
        map2.put("label","健康管理");
        map2.put("name","health");
        map2.put("icon","el-icon-s-custom");

        ArrayList<HashMap<String,String>> arrayList2 = new ArrayList<>();
        HashMap<String,String> map2_1 = new HashMap<>();
        map2_1.put("label","档案管理");
        map2_1.put("path","filesManage");
        map2_1.put("name","filesManage");
        arrayList2.add(map2_1);
        map2.put("children",arrayList2);

//      活动管理
        HashMap<String,Object> map3 = new HashMap<>();
        map3.put("label","活动管理");
        map3.put("name","active");
        map3.put("icon","el-icon-user-solid");

        ArrayList<HashMap<String,String>> arrayList3 = new ArrayList<>();
        HashMap<String,String> map3_1 = new HashMap<>();
        map3_1.put("label","活动审批");
        map3_1.put("path","activeProve");
        map3_1.put("name","activeProve");
        arrayList3.add(map3_1);

        HashMap<String,String> map3_2 = new HashMap<>();
        map3_2.put("label","活动详情");
        map3_2.put("path","detailActive");
        map3_2.put("name","detailActive");
        arrayList3.add(map3_2);
        map3.put("children",arrayList3);

        list.add(map1);
        list.add(map2);
        list.add(map3);

        return list;
    }

//    员工的菜单
    public static List<HashMap<String,Object>> getEmployeeMenuList(){
        //      总的数组
        List<HashMap<String,Object>> list = new ArrayList<>();

//      功能模块
        HashMap<String,Object> map1 = new HashMap<>();
        map1.put("label","功能模块");
        map1.put("name","userOlder");
        map1.put("icon","el-icon-s-platform");

        ArrayList<HashMap<String,String>> arrayList1 = new ArrayList<>();
        HashMap<String,String> map1_1 = new HashMap<>();
        map1_1.put("label","新增档案");
        map1_1.put("path","userAddFiles");
        map1_1.put("name","userAddFiles");
        arrayList1.add(map1_1);

        HashMap<String,String> map1_2 = new HashMap<>();
        map1_2.put("label","申请活动");
        map1_2.put("path","userCreateActive");
        map1_2.put("name","userCreateActive");
        arrayList1.add(map1_2);

        HashMap<String,String> map1_3 = new HashMap<>();
        map1_3.put("label","申请列表");
        map1_3.put("path","userActiveList");
        map1_3.put("name","userActiveList");
        arrayList1.add(map1_3);

        HashMap<String,String> map1_4 = new HashMap<>();
        map1_4.put("label","审批报名");
        map1_4.put("path","userProveJoin");
        map1_4.put("name","userProveJoin");
        arrayList1.add(map1_4);

        map1.put("children",arrayList1);

        list.add(map1);

        return list;
    };

//    截取前21个字符
    public static void interceptBefore21(List<Notice> noticeList){
        for (Notice item:noticeList) {
            if(item.getContext().length()>21){
                item.setContext(item.getContext().substring(0,21)+"...");
            }
        }
    }
}
